package cn.liye.pingfen.controller;


import cn.liye.pingfen.pojo.dto.CommentDTO;
import cn.liye.pingfen.pojo.vo.CommentVO;
import cn.liye.pingfen.response.JsonResult;
import cn.liye.pingfen.service.ICommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@ApiOperation("评论模块")
@RestController
@RequestMapping("/v1/comment")
public class CommentController {
    @Autowired
    ICommentService service;

    @ApiOperation("添加评论")
    @PostMapping("/add-new")
    public JsonResult addNew(CommentDTO commentDTO){
        service.addNew(commentDTO);
        return JsonResult.ok();
    }

    @ApiOperation("获取评论")
    @GetMapping("/{companyId}")
    public JsonResult listById(@PathVariable Long companyId){
        List<CommentVO> list = service.listById(companyId);
        return JsonResult.ok(list);
    }
}
